package com.xmut.eduservice.controller;


import com.xmut.commonutils.R;
import com.xmut.eduservice.entity.EduSubject;
import com.xmut.eduservice.entity.subject.OneSubject;
import com.xmut.eduservice.service.EduSubjectService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author huangchaoqin
 * @since 2020-08-02
 */
@RestController
@RequestMapping("/eduservice/edu-subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;


    // 添加课程分类
    // 获取盛传过来的文件，把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file) {
        subjectService.saveSubject(file, subjectService);
        return R.ok();
    }

    // 课程分类列表，树形结构
    @GetMapping("getAllSubject")
    public R getAllSubhect() {
        List<OneSubject> list = subjectService.getAllOneTwoSubject();
        System.out.println(list);
        return R.ok().data("list", list);
    }
}

